package com.victor.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.victor.dao.BannerDao;
import com.victor.entity.Age;
import com.victor.entity.Banner;
import com.victor.entity.BannerToGrowplan;
import com.victor.service.BannerService;

@Service
public class BannerServiceImpl implements BannerService {

	@Autowired
	private BannerDao bannerDao;

//	获取banner图列表
	@Override
	public List<Banner> getAllBanner() {
		return bannerDao.getAllBanner();
	}

	// 通过bannerid获取banner详情
	@Override
	public Banner getBannerXqByid(String bannerid) {
		return bannerDao.getBannerXqByid(bannerid);
	}

	// 获取年龄段列表
	@Override
	public List<Age> getAllAgeList() {
		return bannerDao.getAllAgeList();
	}

	// 用bannerid和ageid查询绘本列表和年龄段关系
	@Override
	public List<BannerToGrowplan> getPicturebookByBannerAndAge(String bannerid, String ageid) {
		return bannerDao.getPicturebookByBannerAndAge(bannerid, ageid);
	}

	// 通过四个参数去查询是否有数据
	@Override
	public BannerToGrowplan getBannerToGrowplanByAll(BannerToGrowplan bannerToGrowplan) {
		return bannerDao.getBannerToGrowplanByAll(bannerToGrowplan);
	}

	// 添加绘本 传添加到那个年龄,添加的banner图,添加的月份,图书id
	@Override
	public boolean addBannerPicture(BannerToGrowplan bannerToGrowplan) {
		return bannerDao.addBannerPicture(bannerToGrowplan) > 0 ? true : false;
	}

	// 删除banner中绘本
	@Override
	public boolean delBannerPicturebook(Integer bannertogrowplanid) {
		return bannerDao.delBannerPicturebook(bannertogrowplanid) > 0 ? true : false;
	}

	// 批量删除 通过id数组
	@Override
	public boolean delBannerPicturebookByids(int ids) {
		return bannerDao.delBannerPicturebookByids(ids) > 0 ? true : false;
	}

	// 修改banner信息
	@Override
	public boolean updateBanner(Banner banner) {
		return bannerDao.updateBanner(banner) > 0 ? true : false;
	}
}
